﻿function Cancella_Distinta(id_movimento_carico) {
    var url = '/api/Movimenti/CancellaDistintaCarico';

    var m_data = JSON.stringify({ IdMovimento: id_movimento_carico });

    $.ajax({
        type: "POST",
        url: url,
        data: m_data,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (response) {
            ShowResponseMessage(response);

            m_tableJQDTTable.clear().draw();
            //AzzeraDati();
        },
        failure: function (response) {
            alert(response);
        }
    });
}

function CancellaElementoDistinta(idMovimento, data, rowIndex, url, tipo) {
    
    var m_data = JSON.stringify({ IdMovimento: idMovimento, data: data });

    $.ajax({
        type: "POST",
        url: url,
        data: m_data,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (response) {
            if (response.Value) {

                if (tipo == 1) {
                    $("#formly_1_asyncselect_Articolo_0").val("");
                    $('#formly_1_inputnumber_Quantita_1').val("");
                }

                alert(response.Message);
                m_tableJQDTTable.row(rowIndex).remove().draw();
            } else {
                if (response.HasError) {
                    alert(response.Error.Message);
                } else {
                    alert(response.Message);
                    ShowResponseMessage(response.Message);
                }
            }
        },
        failure: function (response) {
            alert(response);
        }
    });
}